# -*- coding: utf-8 -*-
from django.db import models
from apps.basic.models import *
from apps.gis_analysis.conf import *

class SpecialArea(models.Model):
    code = models.CharField('特殊区域编码', max_length=20, unique=True)
    name = models.CharField('特殊区域名称', max_length=40, unique=True)
    line = models.ForeignKey(Line, verbose_name='输电线路',
            null=True, blank=True)
    fromTower = models.ForeignKey(Tower, verbose_name='起始杆塔',
            related_name='fromspecial_areas', null=True, blank=True)
    toTower = models.ForeignKey(Tower, verbose_name='终止杆塔', 
            related_name='tospecial_areas', null=True, blank=True)
#    specialAreaType = models.CharField(choices=SPECIAL_AREA_TYPE,\
#            '特殊区域类型', max_length=40, null=True, blank=True)
    specialAreaType = models.CharField('特殊区域', choices=SPECIAL_AREA_TYPE,
            max_length=20, null=True, blank=True)
    reason = models.TextField('形成原因', null=True, blank=True)
    remarks = models.TextField('特殊区域简介', null=True, blank=True)

    def __unicode__(self):
        return self.name

    class Meta:
        verbose_name = '特殊区域'
        verbose_name_plural = '特殊区域(SpecialArea)'


#class Nasty(models.Model):
#    code = models.CharField('污秽区编码', max_length=20)
#    name = models.CharField('污秽区名称', max_length=40)
#    grade = models.CharField('污秽区等级', max_length=20, choices=(('1','一级'),
#                ('2','二级'), ('3','三级'), ('4','四级')))
#    def __unicode__(self):
#        return self.name
#    
#    class Meta:
#        verbose_name = '污秽区(Nasty)'
#        verbose_name_plural = 'GIS分析|污秽区(Nasty)'
 
class NastyAnalysis(models.Model):
#    nasty = models.ForeignKey(Nasty, verbose_name='污秽区', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='杆塔', null=True, blank=True)
    summary = models.TextField('污秽区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name
    
    class Meta:
        verbose_name = '污秽区分析 NastyAnalysis'
        verbose_name_plural = 'GIS分析|污秽区分析(NastyAnalysis)'


#class Bird(models.Model):
#    code = models.CharField('鸟害易发区编码', max_length=20)
#    name = models.CharField('鸟害易发区名称', max_length=40)
#    
#    def __unicode__(self):
#        return self.name
#    
#    class Meta:
#        verbose_name = '鸟害易发区 Bird'
#        verbose_name_plural = 'GIS分析|鸟害易发区(Bird)'
 
class BirdAnalysis(models.Model):
#    bird = models.ForeignKey(Bird, verbose_name='鸟害易发区', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='杆塔', null=True, blank=True)
    summary = models.TextField('鸟害易发区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name
    
    class Meta:
        verbose_name = '鸟害易发区分析 BirdAnalysis'
        verbose_name_plural = 'GIS分析|鸟害易发区分析(BirdAnalysis)'

#class Goaf(models.Model):
#    code = models.CharField('采空区编码', max_length=20)
#    name = models.CharField('采空区名称', max_length=40)
#    
#    def __unicode__(self):
#        return self.name
#
#    class Meta:
#        verbose_name = '采空区 Goaf'
#        verbose_name_plural = 'GIS分析|采空区(Goaf)'

        
class GoafAnalysis(models.Model):
#    goaf = models.ForeignKey(Goaf, verbose_name='采空区', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='处在特殊区域的变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='处在特殊区域的输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='处在特殊区域的杆塔', null=True, blank=True)
    summary = models.TextField('采空区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name

    class Meta:
        verbose_name = '采空区分析 GoafAnalysis'
        verbose_name_plural = 'GIS分析|采空区分析(GoafAnalysis)'


#class Wind(models.Model):
#    code = models.CharField('风害区编码', max_length=20)
#    name = models.CharField('风害区名称', max_length=40)
#    
#    def __unicode__(self):
#        return self.name
#    class Meta:
#        verbose_name = '风害区 Wind'
#        verbose_name_plural = 'GIS分析|风害区(Wind)'


class WindAnalysis(models.Model):
#    wind = models.ForeignKey(Wind, verbose_name='风暴去', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='处在特殊区域的变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='处在特殊区域的输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='处在特殊区域的杆塔', null=True, blank=True)
    summary = models.TextField('风害区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name
    
    class Meta:
        verbose_name = '风害区分析 WindAnalysis'
        verbose_name_plural = 'GIS分析|风害区分析(WindAnalysis)'


#class Flood(models.Model):
#    code = models.CharField('洪水冲刷区编码', max_length=20)
#    name = models.CharField('洪水冲刷区名称', max_length=40)
#    
#    def __unicode__(self):
#        return self.name
#    class Meta:
#        verbose_name = '洪水冲刷区 Flood'
#        verbose_name_plural = 'GIS分析|洪水冲刷区(Flood)'


class FloodAnalysis(models.Model):
#    flood = models.ForeignKey(Flood, verbose_name='洪水冲刷区', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='处在特殊区域的变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='处在特殊区域的输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='处在特殊区域的杆塔', null=True, blank=True)
    summary = models.TextField('洪水冲刷区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name
    
    class Meta:
        verbose_name = '洪水冲刷区分析 FloodAnalysis'
        verbose_name_plural = 'GIS分析|洪水冲刷区分析(FloodAnalysis)'


#class Coast(models.Model):
#    code = models.CharField('滑坡沉淀区编码', max_length=20)
#    name = models.CharField('滑坡沉淀区名称', max_length=40)
#    
#    def __unicode__(self):
#        return self.name
#
#    class Meta:
#        verbose_name = '滑坡沉淀区 Coast'
#        verbose_name_plural = 'GIS分析|滑坡沉淀区(Coast)'


class CoastAnalysis(models.Model):
#    coast = models.ForeignKey(Coast, verbose_name='滑坡沉淀区', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='处在特殊区域的变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='处在特殊区域的输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='处在特殊区域的杆塔', null=True, blank=True)
    summary = models.TextField('滑坡沉淀区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name
    
    class Meta:
        verbose_name = '滑坡沉淀区分析 CoastAnalysis'
        verbose_name_plural = 'GIS分析|滑坡沉淀区分析(CoastAnalysis)'


#class Thunder(models.Model):
#    code = models.CharField('雷害区编码', max_length=20)
#    name = models.CharField('雷害区名称', max_length=40)
#    
#    def __unicode__(self):
#        return self.name
#
#    class Meta:
#        verbose_name = '雷害区 Thunder'
#        verbose_name_plural = 'GIS分析|雷害区(Thunder)'

    
class ThunderAnalysis(models.Model):
#    thunder = models.ForeignKey(Thunder, verbose_name='雷害区', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='处在特殊区域的变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='处在特殊区域的输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='处在特殊区域的杆塔', null=True, blank=True)
    summary = models.TextField('雷害区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name
    
    class Meta:
        verbose_name = '雷害区分析 ThunderAnalysis'
        verbose_name = 'GIS分析|雷害区分析(ThunderAnalysis)'


#class Force(models.Model):
#    code = models.CharField('外力破坏区编码', max_length=20)
#    name = models.CharField('外力破坏区名称', max_length=40)
#    
#    def __unicode__(self):
#        return self.name
#    
#    class Meta:
#        verbose_name = '外力破坏区 Force'
#        verbose_name_plural = 'GIS分析|外力破坏区(Force)'

    
class ForceAnalysis(models.Model):
#    force = models.ForeignKey(Force, verbose_name='外力破坏区', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='处在特殊区域的变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='处在特殊区域的输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='处在特殊区域的杆塔', null=True, blank=True)
    summary = models.TextField('外力破坏区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name

    class Meta:
        verbose_name = '外力破坏区分析 ForceAnalysis'
        verbose_name_plural = 'GIS分析|外力破坏区(ForceAnalysis)'


#class Ice(models.Model):
#    code = models.CharField('覆冰区编码', max_length=20)
#    name = models.CharField('覆冰区名称', max_length=40)
#    
#    def __unicode__(self):
#        return self.name
#
#    class Meta:
#        verbose_name = '覆冰区 Ice'
#        verbose_name_plural = 'GIS分析|覆冰区(Ice)'

    
class IceAnalysis(models.Model):
#    ice = models.ForeignKey(Ice, verbose_name='覆冰区', unique=True)
    special_area = models.ForeignKey(SpecialArea, verbose_name='所属特殊区域')
    stations = models.ForeignKey(Station, verbose_name='处在特殊区域的变电站',
            null=True, blank=True)
    lines = models.ForeignKey(Line, verbose_name='处在特殊区域的输电线路', null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='处在特殊区域的杆塔', null=True, blank=True)
    summary = models.TextField('覆冰区简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.special_area.name

    class Meta:
        verbose_name = '覆冰区分析 IceAnalysis'
        verbose_name_plural = 'GIS分析|覆冰区分析(IceAnalysis)'


class ThunderInfo(models.Model):
    code = models.CharField('雷电信息编码', max_length=20)
    name = models.CharField('雷电信息名称', max_length=40)
    
    def __unicode__(self):
        return self.name
    
    class Meta:
        verbose_name = '雷电信息 ThunderInfo'
        verbose_name_plural = 'GIS分析|雷电信息(ThunderInfo)'


class ThunderInfoAnalysis(models.Model):
    thunderinfo = models.ForeignKey(ThunderInfo, verbose_name='雷电信息', unique=True)
    lines = models.ForeignKey(Line, verbose_name='处在雷电区域的输电线路',
            null=True, blank=True)
    towers = models.ForeignKey(Tower, verbose_name='处在雷电区域的杆塔',
            null=True, blank=True)
    summary = models.TextField('雷电信息分析简介', null=True, blank=True)
    
    def __unicode__(self):
        return self.thunderinfo.name
    
    class Meta:
        verbose_name = '雷电信息分析 ThunderInfoAnalysis'
        verbose_name_plural = 'GIS分析|雷电信息分析(ThunderInfoAnalysis)'
